# Maintainer : Christian Rebischke <Chris.Rebischke@archlinux.org>
# Maintainer : Caleb Maclennan <caleb@alerque.com>
# Contributor: Eli Schwartz <eschwartz@archlinux.org>
# Contributor: Giovanni Scafora <giovanni@archlinux.org>
# Contributor: lucke <lucke at o2 dot pl>

pkgname=weechat
pkgver=3.8
pkgrel=2
pkgdesc="Fast, light and extensible IRC client (curses UI)"
arch=('loong64' 'x86_64')
url="https://www.weechat.org/"
license=('GPL')
depends=('gnutls' 'curl' 'libgcrypt')
makedepends=('asciidoctor' 'cmake' 'aspell' 'guile' 'lua' 'perl' 'python'
             'ruby' 'tcl')
optdepends=('aspell: spellchecker support'
            'guile: support for guile scripts'
            'lua: support for lua scripts'
            'perl: support for perl scripts'
            'python: support for python scripts'
            'ruby: support for ruby scripts'
            'tcl: support for tcl scripts')
source=("https://www.weechat.org/files/src/${pkgname}-${pkgver}.tar.xz"{,.asc})
sha512sums=('f2fe125d03e9c8f8b5b03e2cdd340c6cd65c463187bd213c9128a3df19da56ae38f1a6d20a47c09606d1504448e3d554de042e33cc57b73753ce8491595ef516'
            'SKIP')
b2sums=('46a2c2c5f14f1c47c0ef2c7591549e4568c1777a70c571ab6d0e5938685262a0806c1fd301eb0d840245b7df2c42a69b089d6eac82706ae5b2a8e590a910080a'
        'SKIP')
validpgpkeys=('A9AB5AB778FA5C3522FD0378F82F4B16DEC408F8') # WeeChat (signing key) <webmaster@weechat.org>

# cmake does not correctly handle CPPFLAGS, so kludge it in anyway:
# https://gitlab.kitware.com/cmake/cmake/-/issues/12928
CFLAGS+=" ${CPPFLAGS}"

build() {
  mkdir -p build
  cd build
  cmake -Wno-dev "${srcdir}/${pkgname}-${pkgver}" \
        -DCMAKE_INSTALL_PREFIX=/usr \
        -DENABLE_MAN=ON \
        -DENABLE_DOC=ON \
        -DENABLE_JAVASCRIPT=OFF \
        -DENABLE_PHP=OFF
  make
}

package() {
  cd build
  make DESTDIR="${pkgdir}" install
}
